
/**
Business Unit missing in common mart.
1. finish CDC job
2. create a separate Business Unit refresh job
3. Drop article
4. Create article
5. run cdc job
 

**/


use RD4_DWCR
go

select * from JDEGSBusinessUnitMaster
where BUSINESSUNITCODE = '        6004'

select * from RD_Common.dbo.Star_BusinessUnit
where BusinessUnitCode='        6004'



if object_ID('tempBU') is not null
drop table tempBU

select * into tempBU from JDEGSBusinessUnitMaster
where BUSINESSUNITCODE = '        6004'

delete from JDEGSBusinessUnitMaster
where BUSINESSUNITCODE = '        6004'

insert into JDEGSBusinessUnitMaster  select * from tempBU

-- drop article
	if exists(select * from distribution.dbo.MSarticles where article = 'JDEGSBusinessUnitMaster')	
exec sp_droparticle @publication = N'RD4_DWCR', @article = N'JDEGSBusinessUnitMaster', @force_invalidate_snapshot = 1

-- create article

exec sp_addarticle @publication = N'RD4_DWCR', @article = N'JDEGSBusinessUnitMaster', @source_owner = N'dbo', @source_object = N'JDEGSBusinessUnitMaster', @destination_table = N'JDEGSBusinessUnitMaster', @type = N'logbased', @creation_script = null, @description = null, @pre_creation_cmd = N'none', @schema_option = 0x0000000002005081, @status = 0, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_JDEGSBusinessUnitMaster', @del_cmd = N'XCALL sp_MSdel_JDEGSBusinessUnitMaster', @upd_cmd = N'XCALL sp_MSupd_JDEGSBusinessUnitMaster', @filter = null, @sync_object = null, @auto_identity_range = N'false'